package svgedit.gui.commands;

import svgedit.svg.SVGPaint;
import svgedit.svg.SVGStylable;

/**
 * Handles undoing and redoing of fill colour changes
 * @author SARJ
 *
 */
public class ChangeFillCommand implements Command
{

	SVGStylable element;
	SVGPaint oldPaint = new SVGPaint();
	SVGPaint newPaint;

	/**
	 * Consturctor for the command
	 * @param element The element that is being styled
	 * @param newPaint The new paint colour to apply
	 */
	public ChangeFillCommand(SVGStylable element, SVGPaint newPaint)
	{
		this.element = element;
		this.oldPaint.setValueFromPaint(element.getFill());
		this.newPaint = newPaint;
	}

	@Override
	public void executeUndo()
	{
		element.getFill().setValueFromPaint(oldPaint);
	}

	@Override
	public void executeRedo()
	{
		element.getFill().setValueFromPaint(newPaint);

	}

}
